package com.zoe.app.service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.zoe.app.entity.User;
import com.zoe.app.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Zoe.Zhang
 * @date 2021/10/16
 * @description
 */
@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    @DS("master")
    public Long saveUser(User user) {
        int i = userMapper.saveUser(user);
        return user.getId();
    }

    @DS("slave")
    public List<User> listAllUsers(User user) {
        List<User> users = userMapper.listAllUsers(user);
        return users;
    }
}
